package cn.edu.wynu.edusys.controller;

import cn.edu.wynu.edusys.pojo.Dept;
import cn.edu.wynu.edusys.pojo.Result;
import cn.edu.wynu.edusys.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;

    /**
     * 查询所有部门
     * @return
     */
    @GetMapping("/depts")
    public Result list(){
        List<Dept> deptsList = deptService.list();
        log.info("成功查询到部门数据");
        return Result.success(deptsList);
    }
    /**
     * 按id删除部门
     */
    @DeleteMapping("/depts/{id}")
    public Result delete(@PathVariable Integer id){
        deptService.deptDel(id);
        return Result.success();
    }
}
